import axios from './config'
import domainsFuc from '@/api/domains'
import {TokenKeys} from '@/assets/js/variable'
import Vue from 'vue'
let loadingToast = null;
// 请求拦截
// axios.defaults.withCredentials=true;
axios.interceptors.request.use(function (config) {
    config.params = config.params ? config.params : {};
    if (config.loading) {
    }

    const timestamp = new Date().getTime()+'';
    return continueDone();
    function continueDone() {
        let accessToken = localStorage.getItem(TokenKeys.ACCESS_TOKEN);
        if (config.method === 'get') {
            config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
        } else if (config.method === 'post') {
            if(config.headers['Content-Type'] == 'multipart/form-data'){

            }else{

            }

        }
        config.headers[TokenKeys.ACCESS_TOKEN] = accessToken;
        config.headers.timestamp = timestamp;
        return config

    }
}, function (error) {
    return Promise.reject(error)
});
// 响应拦截

axios.interceptors.response.use(function (response) {

    response = response.data;
    if (response.code != 10000) {


    }

    return response

}, function (error) {

    return Promise.reject(error)
});
export default axios
